package com.atguigu.gmall.product.controller;


import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.model.SpuInfo;
import com.atguigu.gmall.product.service.SpuManageService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/admin/product")
@RestController
public class SpuManageController {

    @GetMapping("/{page}/{size}")
    public Result getSpuListByPage(@PathVariable("page") Long page,
                                   @PathVariable("size") Long size,
                                   @RequestParam(value = "category3Id") Long category3Id) {
        //1.   封装分页对象 Page
        Page<SpuInfo> iPage = new Page<>(page, size);
        //2. 调用业务层完成分页查询
        iPage = SpuManageService.getSpuListByPage(iPage, category3Id);
        return Result.ok(iPage);
    }
}
